<#include "../common/header.ftl"/>
<script>
    $(function () {
        // 修改推荐
        $(".inputBtn").click(function () {
            // 清空模态框
            $("#editForm").get(0).reset();
            // 清除图片
            $("#coverUrl").attr("src", "");
            // 获取json数据
            var json = $(this).data("json");
            // console.log(josn);
            // 将数据设置到模态框中
            if (json) {
                $("#editForm input[name='id']").val(json.id);
                $("#editForm select[name='state']").val(json.state);
                $("#userName").val(json.userName);
            } else {
            }
            // 显示模态框
            $("#hotModal").modal("show");
        });
        // 提交表单
        submitForm(".submitBtn", "#editForm");

        $(".showBtn").click(function () {
            // 获取json数据
            var json = $(this).data("json");
            layer.open({
                title: "点评内容",
                type: 1,
                skin: 'layui-layer-lan', // 样式类名
                closeBtn: 0, // 不显示关闭按钮
                area: ['420px', '240px'], // 宽高
                anim: 3,
                shadeClose: true, // 开启遮罩关闭
                content: json.content
            });
        });

        // 下拉列表值改变事件
        $("#starNumSelect").change(function () {
            // 提交表单
            $("#searchForm").submit();
        });
    });
</script>
</head>
<body>

<!--图片上传表单-->
<#include "../common/img.ftl"/>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#-- 往数据模型中填充一个属性 -->
            <#assign menu="strategyComment"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">攻略点评管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategyComment/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="用户/内容"/>
                </div>
                <button class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <div class="form-group">
                    <label>点评星数:</label>
                    <select class="form-control" name="starNum" id="starNumSelect">
                        <option value="-1">全部</option>
                        <option value="1">一星</option>
                        <option value="2">二星</option>
                        <option value="3">三星</option>
                        <option value="4">四星</option>
                        <option value="5">五星</option>
                    </select>
                    <script>
                        $("#starNumSelect").val(${(qo.starNum)!});
                    </script>
                </div>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>编号</th>
                    <th>点评用户</th>
                    <th>创建时间</th>
                    <th>推荐时间</th>
                    <th>星数</th>
                    <th>所属攻略</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>

                <#-- 循环迭代指令 -->
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.user.nickName}</td>
                        <td>${(entity.createTime?string("yyyy-MM-dd"))!}</td>
                        <td>${(entity.commendTime?string("yyyy-MM-dd"))!"未设置推荐"}</td>
                        <td>${entity.starImg}</td>
                        <td>${(entity.strategy.title)!}</td>
                        <td>${entity.stateName}</td>
                        <td>
                            <a class="btn btn-info btn-xs showBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-list-alt"></span> 查看点评
                            </a>
                            <a class="btn btn-info btn-xs inputBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-leaf"></span> 修改状态
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<!-- 模态框必须作为body的子标签 -->
<div class="modal fade" id="hotModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">修改状态</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyComment/updateState.do" method="post" id="editForm">
                    <!--攻略点评的id-->
                    <input type="text" name="id" hidden>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">点评用户：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="userName" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">点评状态：</label>
                        <div class="col-sm-6">
                            <select id="auditState" class="form-control" autocomplete="off" name="state">
                                <option value="0">普通</option>
                                <option value="1">热门</option>
                                <option value="-1">禁用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    <span class="glyphicon glyphicon-off"></span> 关闭
                </button>
                <button type="button" class="btn btn-primary submitBtn">
                    <span class="glyphicon glyphicon-saved"></span> 保存
                </button>
            </div>
        </div>
    </div>
</div>


</body>
</html>